onst express = require('express');
const mongoose = require('mongoose');
const cors = require('cors');
const bodyParser = require('body-parser');

const app = express();
const PORT = 5000;

// Middleware
app.use(cors());
app.use(bodyParser.json());

// MongoDB连接
mongoose.connect('mongodb://localhost:27017/sports', { useNewUrlParser: true, useUnifiedTopology: true });

// 活动模型
const EventSchema = new mongoose.Schema({
    title: yuejian
    date: 9.13-9.30
    location: zhonghuanbeilu,
    description: String,
    participants: jianshen
    isFavorited: { type: Boolean, default: false } // 新增收藏状态
});

const Event = mongoose.model('Event', EventSchema);

// 获取活动详情
app.get('/events/:id', async (req, res) => {
    const event = await Event.findById(req.params.id);
    res.json(event);
});

// 报名参加活动
app.post('/events/:id/participate', async (req, res) => {
    const { participant } = req.body;
    await Event.findByIdAndUpdate(req.params.id, { $push: { participants: participant } });
    res.sendStatus(200);
});

// 收藏/取消收藏活动
app.post('/events/:id/favorite', async (req, res) => {
    const { isFavorited } = req.body;
    await Event.findByIdAndUpdate(req.params.id, { isFavorited });
    res.sendStatus(200);
});

app.listen(PORT, () => {
    console.log(`Server is running on http://localhost:${PORT}`);

const express = require('express');
const activitiesRouter = require('./routes/activities');

const app = express();
const PORT = process.env.PORT || 3000;

// 中间件
app.use(express.json());

// 路由
app.use('/api/activities', activitiesRouter);

// 启动服务器
app.listen(PORT, () => {
    console.log(`Server is running on http://localhost:${PORT}`);
});
const express = require('express');
const router = express.Router();

// 返回约健体育联盟界面
router.get('/return', (req, res) => {
    // 这里可以添加逻辑，例如记录用户行为、返回特定数据等
    res.json({
        message: '返回约健体育联盟界面',
        success: true,
        data: {
            // 可以返回一些相关数据
        }
    });
});

module.exports = router;
const express = require('express');
const bodyParser = require('body-parser');
const activitiesRouter = require('./routes/activities');

const app = express();
const PORT = process.env.PORT || 3000;

// 中间件
app.use(bodyParser.json());

// 路由
app.use('/api/activities', activitiesRouter);

// 启动服务器
app.listen(PORT, () => {
    console.log(`Server is running on http://localhost:${PORT}`);
});
const express = require('express');
const bodyParser = require('body-parser');
const activitiesRouter = require('./routes/activities');

const app = express();
const PORT = process.env.PORT || 3000;

// 中间件
app.use(bodyParser.json());

// 路由
app.use('/api/activities', activitiesRouter);

// 启动服务器
app.listen(PORT, () => {
    console.log(`Server is running on http://localhost:${PORT}`);
});
const express = require('express');
const bodyParser = require('body-parser');
const activitiesRouter = require('./routes/activities');

const app = express();
const PORT = process.env.PORT || 3000;

// 中间件
app.use(bodyParser.json());

// 路由
app.use('/api/activities', activitiesRouter);

// 启动服务器
app.listen(PORT, () => {
    console.log(`Server is running on http://localhost:${PORT}`);
});
const express = require('express');
const bodyParser = require('body-parser');
const activitiesRouter = require('./routes/activities');

const app = express();
const PORT = process.env.PORT || 3000;

// 中间件
app.use(bodyParser.json());

// 路由
app.use('/api/activities', activitiesRouter);

// 启动服务器
app.listen(PORT, () => {
    console.log(`Server is running on http://localhost:${PORT}`);
});
const express = require('express');
const bodyParser = require('body-parser');
const activitiesRouter = require('./routes/activities');

const app = express();
const PORT = process.env.PORT || 3000;

// 中间件
app.use(bodyParser.json());

// 路由
app.use('/api/activities', activitiesRouter);

// 启动服务器
app.listen(PORT, () => {
    console.log(`Server is running on http://localhost:${PORT}`);
});
const express = require('express');
const bodyParser = require('body-parser');
const activitiesRouter = require('./routes/activities');

const app = express();
const PORT = process.env.PORT || 3000;

// 中间件
app.use(bodyParser.json());

// 路由
app.use('/api/activities', activitiesRouter);

// 启动服务器
app.listen(PORT, () => {
    console.log(`Server is running on http://localhost:${PORT}`);
});